﻿package engine {
	import types.BlockType;
	import types.ValveType;
	
	public class Block {
		
		public var stroke:Number; //milimeters
		public var bore:Number; //milimeters
		public var type:int;
		public var cylinderCount:int;
		public var valveCountByCylinder:int;
		private var _radius:int;
		private var _cylinders:Vector.<Cylinder>;
		private var _valves:Vector.<Valve>;
		
		public function Block(){
			bore = 81;
			stroke = 77.4;
			cylinderCount = 4;
			valveCountByCylinder = 4;
			
			//SETTINGS FOR DEFAULT ENGINE
			type = BlockType.INLINE;
			
			_cylinders = new Vector.<Cylinder>();
			_valves = new Vector.<Valve>();
			for (var i:int = 0; i < cylinderCount; i++) 
			{
				var cyl:Cylinder = new Cylinder();
				cyl.id = i;
				cyl
				_cylinders.push(cyl);
				
				for (var jj:int = 0; jj < valveCountByCylinder; jj++) 
				{
					var valve:Valve = new Valve();
					valve.master = _cylinders[i].id;
					valve.type = jj % valveCountByCylinder < 2 ? ValveType.INPUT : ValveType.OUTPUT;
					_valves.push(valve);
				}
			}
			
			//SETTINGS FOR DEFAULT ENGINE
		}
		
		public function getVolume():Number {
			return (Math.PI / 4) * Math.pow(bore, 2) * stroke * _cylinders.length;
		}
		
		public function getVolumePerCylinder():Number {
			return (Math.PI / 4) * Math.pow(bore, 2) * stroke;
		}
		
	}
	
}